export const touchDirection = (direction, el, callback) => {
  var touchStartX = 0;
  var touchStartY = 0;
  var touchEndX = 0;
  var touchEndY = 0;
  el.addEventListener("touchstart", function (e) {
    touchStartX = e.changedTouches[0].pageX;
    touchStartY = e.changedTouches[0].pageY;
  });
  el.addEventListener("touchend", function (e) {
    touchEndX = e.changedTouches[0].pageX;
    touchEndY = e.changedTouches[0].pageY;
    if (touchStartX - touchEndX > 150 && direction === "left") {
      callback({ left: true, right: false, top: false, bottom: false }, e);
    } else if (touchStartX - touchEndX < -150 && direction === "right") {
      callback({ left: false, right: true, top: false, bottom: false }, e);
    } else if (touchStartY - touchEndY > 150 && direction === "top") {
      callback({ left: false, right: false, top: true, bottom: false }, e);
    } else if (touchStartY - touchEndY < -150 && direction === "bottom") {
      callback({ left: false, right: false, top: false, bottom: true }, e);
    }
  });
};
